# @Time : 2024-10-17 12:48
# @Author : Fioman 
# @Phone : 13149920693
"""
Python中的运算符,包括算术运算符,比较运算符,逻辑运算符
"""
# region 1. 算术运算符
# 1. 加减乘除
a = 10
b = 3
print("Addition: ", a + b)
print("Subtraction: ", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)
# 2. 取模和整除
print("Modulus:", a % b)  # 返回余数
print("Division without the remainder:", a // b)  # 返回商的整数部分3
# 3. 求幂,求乘方
print("Exponentiation: ", 2 ** 3)  # 2 的 3次方,最后结果是8
# 4. 加上=号 比如 += -= *= /= 等
a += b
print("(a += b) 等价于(  a = a + b)", a)
a -= b
print("(a -= b ) 等价于 (a = a - b)", a)
a = 10
a *= b
print("(a *= b) 等价于 (a = a*b))", a)
a = 10
a /= b
print("(a /=b) 等价于 (a = a / b)", a)
a = 10
a %= b
print("(a %= b) 等价于 (a = a % b)", a)
a = 10
a //= b
print("(a //= b) 等价于 (a = a // b)", a)
a = 10
a **= b
print("(a **= b) 等价于 (a = a ** b)", a)
a = 10
a &= b
print("(a &=b) 等价于 (a = a & b)", a)
a = 10
a |= b
print("(a |= b) 等价于 (a = a | b)", a)
a = 10
a ^= b
print("(a ^= b) 等价于 (a = a ^ b)", a)
a = 10
a >>= b
print("(a >>=b) 等价于 (a = a >> b)", a)
a = 10
a <<= b
print("(a <<= b)等价于 (a = a << b)", a)
# endregion

# region 2. 比较运算符,返回的结果是True 或者 False
# 1. == Equal
print(3 == 2)  # False
# 2. != Not Equal
print(3 != 2)  # True
# 3. > Greater than
print(3 > 2)  # True
# 4. < lessThan
print(3 < 2)  # False
# 5. >= Greater Than or equal to
print(2 >= 3)  # False
# 6. <= Less than or eaqual to
print(2 <= 3)  # True
# 7. is 如果变量相等,返回True,比较是否是同一个对象
print("1 is 1", 1 is 1)  # 这里有警告,就是数字的时候建议使用 == 来进行比较
print("1  == 1", 1 == 1)
print("None is False:", None is False)
# 8. is not
print("1 is not None:", 1 is not None)
# 9. in
print("in 的使用: ", "A" in "ABC")
# 10. not in
print("not in 的使用: ", "A" not in "ABC")
# endregion

# region 3. 逻辑运算符
# 不像其他的语言,Python使用and or not来表示逻辑运算.
# and 逻辑与   当and的左右两边都返回True的时候才返回True
# or   逻辑或   当or左右两边有一个为真的时候,就返回True
# not 逻辑非   将结果的True和False进行反转,比如True变成False,False变成True
print((3 > 2) and (4 > 3))  # True
print((3 > 2) and (4 < 3))  # False
print((3 > 2) or (4 > 3))  # True
print(not 3 > 2)  # False
print(not 2 > 3 and 3 > 2 and (4 > 3 or 5 < 4))
# 注意在使用多个的时候要注意使用括号
print((3 > 2 or 2 < 4) and 5 > 4 and not 3 < 2)
# endregion
